import React from 'react';
import './03.css';
import {random as r} from 'lodash';

class ChangeBg extends React.Component{
  //声明状态
  state = {
    bg: 'rgb(200, 200, 200)'
  }
  render(){
    return <div className='box' style={{background: this.state.bg}} onClick={() => {
      //更新状态
      this.setState({
        bg: `rgb(${r(0,100)},${r(0,100)},${r(0, 100)})`
      })
    }}></div>
  }
}

//暴露
export default ChangeBg;